<!--info.css-->
<template>
	<section id="info">
		<section class="userinfo">
			<section class="setup">
				<router-link to='systemset'>
					<i class="van-icon van-icon-setting"></i>
				</router-link>

			</section>
			<header>
				<section class="userPortrait info">
					<i class="van-icon van-icon-contact"></i>
				</section>
				<section class="mobelTitle info" v-if="login">
					<span class="phone">{{$public.phoneEncryption(userData.mobile)}}</span>
					<p class="uid">UID:{{userData.account}}</p>
				</section>
				<section class="mobelTitle info" @click="goList('/login')" v-else>
					<span class="phone">请登录</span>
					<p class="uid">欢迎登录 XXX</p>
				</section>
				<section class="signWarp info" v-show="login">
					<p><i class="van-icon van-icon-edit"></i></p>
					<span>签到</span>
				</section>
			</header>
			<section class="balance">
				<a href="#">
					<p class="dataNum" v-if="login">{{userData.wallone}}</p>
					<p class="dataNum" v-else>--</p>
					<p class="dataName">账户余额 (USDT)</p>
				</a>
			</section>

			<section class="usernav">
				<ul class="lisWarp">
					<li class="lis" v-for="(v,index) in infoNav" :key='index' @click="goList(v.url)">
						<a href="#">
							<i :class="v.icon"></i>
							<span>{{v.title}}</span>
							<i class="van-icon van-icon-arrow"></i>
							<!--<i class="mixiNum" v-show="index=='2'">0</i>-->
						</a>
					</li>

				</ul>
			</section>

		</section>

		<FooTer :Active="3"></FooTer>
	</section>
</template>
<script>
	import Footer from "./common/footer.vue";
	export default {
		// 数据
		data() {
			//'个人中心','安全中心','抢筹明细','账户充值','账户提现','邀请好友','关于我们'
			return {
				infoNav: [{
						'icon': 'van-icon van-icon-browsing-history',
						'title': '个人中心',
						'url': 'personalcenter'
					},
					{
						'icon': 'van-icon van-icon-browsing-history',
						'title': '安全中心',
						'url': 'security'
					},
//					{
//						'icon': 'van-icon van-icon-browsing-history',
//						'title': '抢筹明细',
//						'url': 'qclist'
//					},
					{
						'icon': 'van-icon van-icon-browsing-history',
						'title': '账户充值',
						'url': 'recharge'
					},
					{
						'icon': 'van-icon van-icon-browsing-history',
						'title': '账户提现',
						'url': 'withdrawal'
					},
					{
						'icon': 'van-icon van-icon-browsing-history',
						'title': '邀请好友',
						'url': 'invitefriends'
					},
					{
						'icon': 'van-icon van-icon-browsing-history',
						'title': '关于我们',
						'url': 'aboutus'
					}
				],
				login:false,  //判断登录标志位 false 为没有登录 true为登录
				userData:''  //用户信息

			};
		},
		// 当数据发生改变时
		watch: {},
		// 方法
		methods: {
			
			goList(urls) {
				var _this = this;
				if(!_this.login){
					_this.$public.go('/login', 0, _this);
					return false;
				}
				var urls = '/' + urls;
				console.log(urls);
				_this.$public.go(urls, 0, _this);
			},
			//判断有没有登录 没有登录提示登录 登录后请求个人心中信息
			islogin() {
				var _this = this;
				if(!_this.$public.islogin()) {
					_this.$toast('请先登录');
					_this.login = false;
					return false;
				}else{
					_this.login = true;
					//请求个人数据信息
					_this.$public.userInfo({
						_this:_this,
						mobile:sessionStorage.mobile,
						sfun:function(data){
							_this.userData = data.data.data;
						}
					})
				}
			}
		},

		// 路由发生变化时
		beforeRouteLeave(to, from, next) {
			var conent = this;
			next()
		},

		// 加载模块
		components: {
			"FooTer": Footer
		},
		// 加载执行
		created: function() {
			this.islogin();
		}
	};
</script>